<template>
  <div class="app-container">
    <div class="filter-container default-box">
      <el-row type="flex" align="middle">
        <el-col :span="21">
          <el-row type="flex" :gutter="150" class="filter-row">
            <el-col :span="8">
              <span>卖家ID：</span>
              <el-input v-model="listQuery.title" placeholder="请输入卖家ID" class="filter-item" />
            </el-col>
            <el-col :span="8">
              <span>买家ID：</span>
              <el-input v-model="listQuery.title" placeholder="请输入买家ID" class="filter-item" />
            </el-col>
          </el-row>
          <el-row type="flex" justify="space-between" :gutter="150" class="filter-row">
            <el-col :span="8">
              <span>卖家账号：</span>
              <el-input v-model="listQuery.title" placeholder="请输入卖家账号" class="filter-item" />
            </el-col>
            <el-col :span="8">
              <span>买家账号：</span>
              <el-input v-model="listQuery.title" placeholder="请输入买家账号" class="filter-item" />
            </el-col>
            <el-col :span="8">
              <span>订单号：</span>
              <el-input v-model="listQuery.title" placeholder="请输入订单号" class="filter-item" />
            </el-col>
          </el-row>
          <el-row type="flex" justify="space-between" :gutter="150" class="filter-row">
            <el-col :span="8">
              <span>卖家状态：</span>
              <el-select v-model="statusvalue" filterable placeholder="请选择">
                <el-option v-for="item in statusoptions" :key="item.value" :label="item.label" :value="item.value" />
              </el-select>
            </el-col>
            <el-col :span="8">
              <span>订单状态：</span>
              <el-select v-model="statusvalue" filterable placeholder="请选择">
                <el-option v-for="item in statusoptions" :key="item.value" :label="item.label" :value="item.value" />
              </el-select>
            </el-col>
            <el-col :span="8">
              <span>反馈状态：</span>
              <el-select v-model="statusvalue" filterable placeholder="请选择">
                <el-option v-for="item in statusoptions" :key="item.value" :label="item.label" :value="item.value" />
              </el-select>
            </el-col>
          </el-row>
        </el-col>
        <el-col :span="3" class="fliter-btn">
          <el-col :span="24" class="filter-row">
            <el-button class="filter-item" type="primary" icon="el-icon-search" round>
              查询
            </el-button>
          </el-col>
          <el-col :span="24" class="filter-row">
            <el-button class="filter-item" icon="el-icon-refresh-right" round>
              重置
            </el-button>
          </el-col>
        </el-col>
      </el-row>
    </div>
    <div class="default-box">
      <el-table
        :key="tableKey"
        v-loading="listLoading"
        :data="list"
        fit
        highlight-current-row
        style="width: 100%;"
      >
        <el-table-column label="交易ID" min-width="200" show-overflow-tooltip>
          <template>
            <span>19</span>
          </template>
        </el-table-column>
        <el-table-column label="订单号" min-width="250" show-overflow-tooltip>
          <template>
            <span>1832472945246464645666665</span>
          </template>
        </el-table-column>
        <el-table-column label="卖家" min-width="200" show-overflow-tooltip>
          <template>
            <span>18324729452</span>
          </template>
        </el-table-column>
        <el-table-column label="买家" min-width="200" show-overflow-tooltip>
          <template>
            <span>18324729452</span>
          </template>
        </el-table-column>
        <el-table-column label="广告包" width="150">
          <template>
            <span>家庭旅行包</span>
          </template>
        </el-table-column>
        <el-table-column label="单价" width="150">
          <template>
            <span>30</span>
          </template>
        </el-table-column>
        <el-table-column label="卖出数量" width="150">
          <template>
            <span>30</span>
          </template>
        </el-table-column>
        <el-table-column label="状态" width="150">
          <template>
            <el-button type="text">已完成</el-button>
          </template>
        </el-table-column>
        <el-table-column label="反馈状态" width="200">
          <template>
            <span class="success-color">无申述</span>
          </template>
        </el-table-column>
        <el-table-column label="交易凭证" width="150">
          <template>
            <el-image
              style="width: 38px; height: 38px"
              :src="srcurl"
              :preview-src-list="srcList"
            />
          </template>
        </el-table-column>
        <el-table-column label="创建时间" width="200">
          <template>
            <span>2023-03-04 14:44:52</span>
          </template>
        </el-table-column>
        <el-table-column label="操作" width="200" class-name="small-padding fixed-width">
          <template>
            <el-button type="warning" round>
              关闭交易
            </el-button>
          </template>
        </el-table-column>
      </el-table>
      <pagination v-show="total>0" :total="total" :page.sync="listQuery.page" :limit.sync="listQuery.limit" @pagination="getList" />
    </div>
  </div>
</template>

<script>
import { fetchList } from '@/api/article'
import Pagination from '@/components/Pagination' // secondary package based on el-pagination
export default {
  name: 'Adminrole',
  components: { Pagination },
  data() {
    return {
      tableKey: 0,
      list: null,
      total: 0,
      listLoading: true,
      listQuery: {
        page: 1,
        limit: 10,
        importance: undefined,
        title: undefined,
        type: undefined,
        sort: '+id'
      },
      statusoptions: [{ // 状态选择项组
        value: '',
        label: '全部'
      }, {
        value: '未完成',
        label: '未完成'
      }, {
        value: '认证通过',
        label: '认证通过'
      }],
      statusvalue: '', // 状态的类型
      value1: false,
      srcurl: 'https://fuss10.elemecdn.com/e/5d/4a731a90594a4af544c0c25941171jpeg.jpeg',
      srcList: [
        'https://fuss10.elemecdn.com/8/27/f01c15bb73e1ef3793e64e6b7bbccjpeg.jpeg',
        'https://fuss10.elemecdn.com/1/8e/aeffeb4de74e2fde4bd74fc7b4486jpeg.jpeg'
      ]
    }
  },
  created() {
    this.getList()
  },
  methods: {
    getList() {
      this.listLoading = true
      fetchList(this.listQuery).then(response => {
        this.list = response.data.items
        this.total = response.data.total
        setTimeout(() => {
          this.listLoading = false
        }, 1.5 * 1000)
      })
    }
  }
}
</script>
<style scoped lang="scss">
  [class^=el-icon-], [class*=" el-icon-"]{
    font-size: 16px;
  }
  .small-padding i{
    margin-right: 12px;
  }
  .small-padding i:last-child{
    margin-right: 0px;
  }
  ::v-deep .el-select{
    width: 100%;
  }
  .fliter-btn{
    text-align: center;
  }
  ::v-deep .el-col-8{
    display: flex;
    white-space: nowrap;
    align-items: center;
  }
  .filter-container{
    .filter-row{
      margin-bottom: 16px;
    }
    span{
    width: 100px;
    min-width: 100px;
    text-align: right;
    }
    .filter-item{
      margin-bottom: 0px;
    }
  }
</style>
